#include "netset.h"
#include "ui_netset.h"
#include <QDebug>
#include <QErrorMessage>
NetSet::NetSet(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::NetSet)
{
    ui->setupUi(this);

   ui->textEdit->installEventFilter(this);
//    ui->textEdit->insertHtml("<a href='http://www.baidu.com'>百度</a>");
}

NetSet::~NetSet()
{
    delete ui;
}

bool NetSet::eventFilter(QObject *watched, QEvent *event)
{
    if(watched == ui->textEdit)
    {
        ui->textEdit->setFocusPolicy(Qt::StrongFocus);
        if(event->type() == QEvent::MouseButtonPress)
        {
            qDebug()<<"eventFilter";
            QString url = ui->textEdit->toPlainText();
            qDebug()<<"url:"<<url;
            QDesktopServices::openUrl(QUrl(url));
        }
    }
    return QWidget::eventFilter(watched,event);
}


